/**
 * Copyright(c) kyle.
 */
package org.example.jvm;

/**
 * 动态分派
 *
 * @author kyle
 * @version 1.00.00
 * @since [2020-12-03 11:52]
 * @updateUser [Kyle]
 * @updateRemark [说明本次修改内容]
 * @date [2020-12-03 11:52]
 */
public class DynamicDispatch {
    private static abstract class Human {
        protected abstract void sayHello();
    }

    private static class Man extends Human {
        @Override
        protected void sayHello() {
            System.out.println("man say hello");
        }
    }
    private static class Woman extends Human {
        @Override
        protected void sayHello() {
            System.out.println("woman say hello");
        }
    }

    public static void main(String[] args) {
        Human man =new Man();
        Human woman =new Woman();
        man.sayHello();
        woman.sayHello();
        man=new Woman();
        man.sayHello();
    }
}
